class PositionsController < InheritedResources::Base
  load_resource
  respond_to :json

  def create
    position = AddPosition.run position_params
    render CommandJsonSerializer.as_json position
  end

  def update
    position = UpdatePosition.run position_params.merge(position: @position)
    render CommandJsonSerializer.as_json position
  end

  private
  def permitted_params
    params.permit(:position => [:name, :nature])
  end

  def position_params
    params.require(:position).permit(:name).merge(nature: params[:position][:nature][:name])
  end
end
